﻿<navigation:Page 
    x:Class="ibba.src.norisk.page.PageDeParaAreaSubLimite" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
    xmlns:slc="clr-namespace:ibba.src.slcomponentes;assembly=ibba.src.slcomponentes"
    xmlns:vm="clr-namespace:ibba.src.norisk.ViewModels"
    mc:Ignorable="d"    
    d:DesignWidth="1000" d:DesignHeight="500"
    Title="PageDeParaTiposLimite Page">

    <navigation:Page.Resources>
        <vm:DeParaAreaSublimiteViewModel x:Key="viewModel"/>

        <slc:SwitchConverter x:Key="AreaSLAtivaConverter" 
                             Else="{x:Null}">
            <slc:SwitchCase When="false" Then="Inativo" />
            <slc:SwitchCase When="true" Then="Ativo" />
        </slc:SwitchConverter>

        <slc:SwitchConverter x:Key="StateViewerConverter" 
                             Else="false">
            <slc:SwitchCase When="0" Then="true" />
            <slc:SwitchCase When="1" Then="true" />
        </slc:SwitchConverter>
        <slc:SwitchConverter x:Key="StateEditConverter" 
                             Else="true">
            <slc:SwitchCase When="0" Then="false" />
            <slc:SwitchCase When="1" Then="false" />
        </slc:SwitchConverter>
    </navigation:Page.Resources>

    <Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource viewModel}}">
        <toolkit:BusyIndicator BusyContent="Aguarde..." IsBusy="{Binding Path=IsBusy}" >
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                <ContentControl x:Name="panelMenuBar" Style="{StaticResource ContentSearchBarStyle}" Grid.Row="0"
                                IsEnabled="{Binding StateView, Converter={StaticResource StateViewerConverter}}">
                    <ContentControl.Content>
                        <Grid HorizontalAlignment="Left" VerticalAlignment="Top">
                            <StackPanel Orientation="Horizontal" >
                                <Border CornerRadius="8" Background="WhiteSmoke" Margin="3" Height="30" VerticalAlignment="Top" >
                                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center" Height="28" Margin="15,0,15,0">
                                        <TextBlock Text="Buscar por" VerticalAlignment="Center" Foreground="#FF14517B" Margin="0,0,5,0"/>
                                        <ComboBox VerticalAlignment="Center" Width="200" 
                                                  ItemsSource="{Binding Path=ListaAreasSubLimite, Mode=OneWay}"
                                                  SelectedItem="{Binding Path=AreaSubLimiteSelecionado, Mode=TwoWay}">
                                            <ComboBox.ItemTemplate>
                                                <DataTemplate>
                                                    <StackPanel Orientation="Vertical" MinWidth="150" Margin="0,1,10,1">
                                                        <TextBlock >
                                                        <Run Text="{Binding Path=DescAreaSubLimite}"/>
                                                        <Run Text="{Binding Path=DescAreaLimite, StringFormat='\ ({0\})'}" FontSize="9" Foreground="{StaticResource ColorDetailCombo}"/>
                                                        </TextBlock>
                                                        <StackPanel Orientation="Vertical" HorizontalAlignment="Right">
                                                            <TextBlock FontSize="9" Foreground="{StaticResource ColorDetailCombo}" HorizontalAlignment="Right">
                                                            <Run Text="Id: " Foreground="Black"/>
                                                            <Run Text="{Binding Path=IdAreaSubLimite}" />
                                                            </TextBlock>
                                                            <Border Style="{StaticResource LineBlue}" Width="150" Margin="0,2" HorizontalAlignment="Center"/>
                                                        </StackPanel>
                                                    </StackPanel>
                                                </DataTemplate>
                                            </ComboBox.ItemTemplate>
                                        </ComboBox>
                                        <slc:CustomButtonBar Content="" Cursor="Hand" Margin="10,-2,-15,-5"
                                                             IsEnabled="{Binding EnabledSearchButton}"
                                                             Image="/ibba.src.norisk;component/image/search.png" ImageSizeNormal="25" ImageSizeOver="28"
                                                             Command="{Binding Path=CommandObterPorId}" 
                                                             CommandParameter="{Binding Path=AreaSubLimiteSelecionado.IdAreaSubLimite}"/>
                                    </StackPanel>
                                </Border>                               
                            </StackPanel>
                        </Grid>
                    </ContentControl.Content>
                </ContentControl>

                <Grid x:Name="gridCampos" Margin="5" Grid.Row="1">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>

                    <StackPanel Grid.Row="0" VerticalAlignment="Top" Margin="10,-5,0,10">
                        <TextBlock Foreground="#FF565965"  Margin="0,0,0,2"  >
                                <Run Text="T" FontSize="18" FontFamily="Arial Black"/>
                                <Run Text="ipo " FontSize="15" />
                                <Run Text="L" FontSize="18" FontFamily="Arial Black" />
                                <Run Text="imite" FontSize="15" />
                        </TextBlock>

                        <TextBlock Style="{StaticResource TitleHeader}" Visibility="{Binding Entidade.IdAreaSubLimite, Converter={StaticResource BooleanToVisibilityConverter}}" >
                                <Run Text="{Binding Entidade.DescAreaSubLimite, StringFormat='\{0\}', FallbackValue='SubArea'}"/>
                                <Run Text="{Binding Entidade.DescAreaLimite, StringFormat=' - \{0\}', FallbackValue=' - Area'}"/>
                                <Run Text="{Binding Entidade.Ativo, StringFormat=' [\{0\}]',Converter={StaticResource AreaSLAtivaConverter}, FallbackValue=' [Inativo]'}" FontSize="9" Foreground="Gray" />
                        </TextBlock>

                        <Border Style="{StaticResource LineBlue}" HorizontalAlignment="Left"/>
                    </StackPanel>

                    <TextBlock x:Name="lblMensagemSelecao" Grid.Row="1"
                               Text="Selecione um Tipo de Limite e clique em pesquisar "
                               Visibility="{Binding Entidade.IdAreaSubLimite, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter='!'}"
                               FontFamily="Arial Black" FontSize="18" Foreground="Black" Margin="15,20,0,0" 
                               HorizontalAlignment="Left" VerticalAlignment="Top" />
                    
                    <ContentControl Grid.Row="1" HorizontalAlignment="Center"
                                    Visibility="{Binding Entidade.IdAreaSubLimite, Converter={StaticResource BooleanToVisibilityConverter}}"
                                    IsEnabled="{Binding StateView, Converter={StaticResource StateEditConverter}}">
                                    <!--IsEnabled="{Binding StateView, Converter={StaticResource EqualsToBooleanConverter}, ConverterParameter='Viewing'}">-->
                        <Grid Grid.Row="1" HorizontalAlignment="Center">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="8" />
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="8" />
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>

                            <StackPanel Orientation="Vertical" VerticalAlignment="Top" Grid.Column="0">
                                <StackPanel Orientation="Horizontal" Margin="3,2">
                                    <TextBlock Text=".: Produto Itaú" VerticalAlignment="Center" HorizontalAlignment="Left" />
                                    <Border Style="{StaticResource LineGold}" Margin="5,0" Width="219" />
                                </StackPanel>

                                <StackPanel Orientation="Horizontal" Margin="3,2">
                                    <sdk:AutoCompleteBox x:Name="txtProdutoItau" Width="280" 
                                                         IsTextCompletionEnabled="True" IsTabStop="True" FilterMode="Contains"
                                                         ItemsSource="{Binding Path=ListaProdutosItau}" 
                                                         SelectedItem="{Binding Path=ProdutoItauSelecionado, Mode=TwoWay, ValidatesOnDataErrors=True}"
                                                         ValueMemberPath="CodigoDescricao">
                                        <sdk:AutoCompleteBox.ItemTemplate>
                                            <DataTemplate>
                                                <TextBlock>
                                                        <Run Text="{Binding Path=Codigo, StringFormat='\{0\} - '}" Foreground="Gray" FontSize="9" />
                                                        <Run Text="{Binding Path=Descricao}" />
                                                </TextBlock>
                                            </DataTemplate>
                                        </sdk:AutoCompleteBox.ItemTemplate>
                                    </sdk:AutoCompleteBox>
                                </StackPanel>
                            </StackPanel>

                            <Button HorizontalAlignment="Right" ToolTipService.ToolTip="Adicionar o Produto" Margin="0,42,6,0" VerticalAlignment="Top" 
                                            Command="{Binding CommandAddDetailProdutoItau}"
                                            IsEnabled="{Binding EnabledAddProdutoItau}">
                                <Image Source="{StaticResource IconeAdicionar}" Width="16" Height="16"/>
                            </Button>

                            <CheckBox Name="chkUtilizarProdProc"  
                                      Content="Utilizar no Processamento :." 
                                      FlowDirection="RightToLeft" 
                                      VerticalAlignment="Top" 
                                      HorizontalAlignment="Left" 
                                      Margin="3,48,0,0" 
                                      IsEnabled="{Binding EnabledAddProdutoItau}" 
                                      Checked="chkUtilizarProdProc_Checked"
                                      Unchecked="chkUtilizarProdProc_Checked"/>
                            
                            <sdk:DataGrid Name="dtgProduto" Margin="3,65,3,3"
                                              Style="{StaticResource DataGridDefault}"
                                              MinHeight="285" Width="310" VerticalAlignment="Stretch"
                                              ItemsSource="{Binding DetalheProdutos.Colecao}"
                                              SelectedItem="{Binding DetalheProdutos.DetalheSelecionado, Mode=TwoWay}">
                                <sdk:DataGrid.Effect>
                                    <DropShadowEffect BlurRadius="11" Color="#FFA6ABAD"/>
                                </sdk:DataGrid.Effect>
                                <sdk:DataGrid.Columns>
                                    <sdk:DataGridTemplateColumn Width="22" HeaderStyle="{StaticResource HeaderIconeLixeira}">
                                        <sdk:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <!--<Button Command="{Binding DetalheProdutos.CommandCheckRemove}">-->
                                                <Button x:Name="btnExcluirProdutoItau" Click="btnExcluirProdutoItau_Click">
                                                    <Image Source="{StaticResource IconeRemover}" Width="16" Height="16" />
                                                </Button>
                                            </DataTemplate>
                                        </sdk:DataGridTemplateColumn.CellTemplate>
                                    </sdk:DataGridTemplateColumn>

                                    <sdk:DataGridTemplateColumn Width="22" HeaderStyle="{StaticResource HeaderIconeLapis}">
                                        <sdk:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <Image Source="{Binding ImageStatus}" Width="10" Height="10" />
                                            </DataTemplate>
                                        </sdk:DataGridTemplateColumn.CellTemplate>
                                    </sdk:DataGridTemplateColumn>

                                    <sdk:DataGridTextColumn Header="Descrição do Produto" Binding="{Binding Path=Descricao}"  Width="*"/>

                                    <sdk:DataGridTemplateColumn Width="60" Header="Utilizar">
                                        <sdk:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <CheckBox Name="chkUtilizarProduto" IsChecked="{Binding Path=UtilizaProcessamento}" VerticalAlignment="Center" HorizontalAlignment="Center" Checked="chkUtilizarProduto_Checked" Unchecked="chkUtilizarProduto_Unchecked"/>
                                            </DataTemplate>
                                        </sdk:DataGridTemplateColumn.CellTemplate>
                                    </sdk:DataGridTemplateColumn>

                                </sdk:DataGrid.Columns>
                            </sdk:DataGrid>
                            <sdk:Label Grid.Column="0" Style="{StaticResource LegendBlue}" Margin="0,0,-6,-6"
                                       VerticalAlignment="Bottom" HorizontalAlignment="Right" 
                                       ToolTipService.ToolTip="Quantidade de Produtos"
                                       Content="{Binding DetalheProdutos.Colecao.Count, FallbackValue='0'}"  />
                            
                            <StackPanel Orientation="Vertical" VerticalAlignment="Top" Grid.Column="2">
                                <StackPanel Orientation="Horizontal" Margin="3,2">
                                    <TextBlock Text=".: Estratégia" VerticalAlignment="Center" HorizontalAlignment="Left" />
                                    <Border Style="{StaticResource LineGold}" Margin="5,0" Width="232" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal" Margin="3,2">
                                    <sdk:AutoCompleteBox x:Name="txtEstrategia" Width="280" 
                                                         IsTextCompletionEnabled="True" IsTabStop="True" FilterMode="Contains"
                                                         ItemsSource="{Binding Path=ListaEstrategias}" 
                                                         SelectedItem="{Binding Path=EstrategiaSelecionado, Mode=TwoWay, ValidatesOnDataErrors=True}"
                                                         ValueMemberPath="CodigoDescricao">
                                        <sdk:AutoCompleteBox.ItemTemplate>
                                            <DataTemplate>
                                                <TextBlock>
                                                        <Run Text="{Binding Path=Codigo, StringFormat='\{0\} - '}" Foreground="Gray" FontSize="9" />
                                                        <Run Text="{Binding Path=Descricao}" />
                                                </TextBlock>
                                            </DataTemplate>
                                        </sdk:AutoCompleteBox.ItemTemplate>
                                    </sdk:AutoCompleteBox>
                                </StackPanel>

                                <Button HorizontalAlignment="Right" ToolTipService.ToolTip="Adicionar a Estratégia" Margin="5,-4,7,0" VerticalAlignment="Top"
                                            Command="{Binding CommandAddDetailEstrategia}"
                                            IsEnabled="{Binding EnabledAddEstrategia}">
                                    <Image Source="{StaticResource IconeAdicionar}" Width="16" Height="16"/>
                                </Button>

                                <CheckBox Name="chkUtilizarEstratProc"  
                                          Content="Utilizar no Processamento :." 
                                          FlowDirection="RightToLeft" 
                                          VerticalAlignment="Top" 
                                          HorizontalAlignment="Left" 
                                          Margin="3,-18,0,0" 
                                          IsEnabled="{Binding EnabledAddEstrategia}"
                                          Checked="chkUtilizarEstratProc_Checked"
                                          Unchecked="chkUtilizarEstratProc_Checked"/>

                            </StackPanel>
                            
                            
                            
                            <sdk:DataGrid Name="dtgEstrategia" Grid.Column="2" Margin="3,65,3,3"
                                              Style="{StaticResource DataGridDefault}"
                                              MinHeight="285" Width="310" VerticalAlignment="Stretch"
                                              ItemsSource="{Binding DetalheEstrategias.Colecao}"
                                              SelectedItem="{Binding DetalheEstrategias.DetalheSelecionado, Mode=TwoWay}">
                                <sdk:DataGrid.Effect>
                                    <DropShadowEffect BlurRadius="11" Color="#FFA6ABAD"/>
                                </sdk:DataGrid.Effect>
                                <sdk:DataGrid.Columns>
                                    <sdk:DataGridTemplateColumn Width="22" HeaderStyle="{StaticResource HeaderIconeLixeira}">
                                        <sdk:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <!--<Button Command="{Binding DetalheEstrategias.CommandCheckRemove}">-->
                                                <Button x:Name="btnExcluirEstrategia" Click="btnExcluirEstrategia_Click" >
                                                    <Image Source="{StaticResource IconeRemover}" Width="16" Height="16" />
                                                </Button>
                                            </DataTemplate>
                                        </sdk:DataGridTemplateColumn.CellTemplate>
                                    </sdk:DataGridTemplateColumn>

                                    <sdk:DataGridTemplateColumn Width="22" HeaderStyle="{StaticResource HeaderIconeLapis}">
                                        <sdk:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <!--<Image Source="{StaticResource BulletGreen}" Width="10" Height="10" />-->
                                                <Image Source="{Binding ImageStatus}" Width="10" Height="10" />
                                            </DataTemplate>
                                        </sdk:DataGridTemplateColumn.CellTemplate>
                                    </sdk:DataGridTemplateColumn>

                                    <sdk:DataGridTextColumn Header="Descrição da Estratégia" Binding="{Binding Path=Descricao}"  Width="*" />

                                    <sdk:DataGridTemplateColumn Width="60" Header="Utilizar">
                                        <sdk:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <CheckBox Name="chkUtilizarEstrategia" 
                                                          IsChecked="{Binding 
                                                          Path=UtilizaProcessamento}" 
                                                          VerticalAlignment="Center" 
                                                          HorizontalAlignment="Center"
                                                          Checked="chkUtilizarEstrategia_Checked"
                                                          Unchecked="chkUtilizarEstrategia_Unchecked"/>
                                            </DataTemplate>
                                        </sdk:DataGridTemplateColumn.CellTemplate>
                                    </sdk:DataGridTemplateColumn>
                                    

                                </sdk:DataGrid.Columns>
                            </sdk:DataGrid>
                            <sdk:Label Grid.Column="2" Style="{StaticResource LegendBlue}" Margin="0,0,-6,-6"
                                       VerticalAlignment="Bottom" HorizontalAlignment="Right" 
                                       ToolTipService.ToolTip="Quantidade de Estratégias"
                                       Content="{Binding DetalheEstrategias.Colecao.Count, FallbackValue='0'}"  />

                            <StackPanel Orientation="Vertical" VerticalAlignment="Top" Grid.Column="4">
                                <StackPanel Orientation="Horizontal" Margin="3,2">
                                    <TextBlock Text=".: Área Institucional" VerticalAlignment="Center" HorizontalAlignment="Left" />
                                    <Border Style="{StaticResource LineGold}" Margin="5,0" Width="191" />
                                </StackPanel>

                                <StackPanel Orientation="Horizontal" Margin="3,2">
                                    <sdk:AutoCompleteBox x:Name="txtAreaInstitucional" Width="280"
                                                         IsTextCompletionEnabled="True" IsTabStop="True" FilterMode="Contains"
                                                         ItemsSource="{Binding Path=ListaAreasInstitucionais}" 
                                                         SelectedItem="{Binding Path=AreaInstitucionalSelecionado, Mode=TwoWay, ValidatesOnDataErrors=True}"
                                                         ValueMemberPath="CodigoDescricao">
                                        <sdk:AutoCompleteBox.ItemTemplate>
                                            <DataTemplate>
                                                <TextBlock>
                                                        <Run Text="{Binding Path=Codigo, StringFormat='\{0\} - '}" Foreground="Gray" FontSize="9" />
                                                        <Run Text="{Binding Path=Descricao}" />
                                                </TextBlock>
                                            </DataTemplate>
                                        </sdk:AutoCompleteBox.ItemTemplate>
                                    </sdk:AutoCompleteBox>
                                </StackPanel>

                                <Button HorizontalAlignment="Right" ToolTipService.ToolTip="Adicionar a Área Institucional" Margin="5,-4,7,0" 
                                            Command="{Binding CommandAddDetailAreaInstitucional}"
                                            IsEnabled="{Binding EnabledAddAreaInstitucional}">
                                    <Image Source="{StaticResource IconeAdicionar}" Width="16" Height="16"/>
                                </Button>

                                <CheckBox Name="chkUtilizarAreaProc"  
                                          Content="Utilizar no Processamento :." 
                                          FlowDirection="RightToLeft" 
                                          VerticalAlignment="Top" 
                                          HorizontalAlignment="Left" 
                                          Margin="3,-18,0,0" 
                                          IsEnabled="{Binding EnabledAddAreaInstitucional}"
                                          Checked="chkUtilizarAreaProc_Checked"
                                          Unchecked="chkUtilizarAreaProc_Checked"/>

                            </StackPanel>
                            <sdk:DataGrid Name="dtgAreaInst" Grid.Column="4" Margin="3,65,3,3"
                                              Style="{StaticResource DataGridDefault}"
                                              MinHeight="285" Width="310" VerticalAlignment="Stretch"
                                              ItemsSource="{Binding DetalheAreasInstitucionais.Colecao}"
                                              SelectedItem="{Binding DetalheAreasInstitucionais.DetalheSelecionado, Mode=TwoWay}">
                                <sdk:DataGrid.Effect>
                                    <DropShadowEffect BlurRadius="11" Color="#FFA6ABAD"/>
                                </sdk:DataGrid.Effect>
                                <sdk:DataGrid.Columns>
                                    <sdk:DataGridTemplateColumn Width="22" HeaderStyle="{StaticResource HeaderIconeLixeira}">
                                        <sdk:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <Button x:Name="btnExcluirAreaInstitucional" Click="btnExcluirAreaInstitucional_Click">
                                                    <Image Source="{StaticResource IconeRemover}" Width="16" Height="16" />
                                                </Button>
                                            </DataTemplate>
                                        </sdk:DataGridTemplateColumn.CellTemplate>
                                    </sdk:DataGridTemplateColumn>

                                    <sdk:DataGridTemplateColumn Width="22" HeaderStyle="{StaticResource HeaderIconeLapis}">
                                        <sdk:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <Image Source="{Binding ImageStatus}" Width="10" Height="10" />
                                            </DataTemplate>
                                        </sdk:DataGridTemplateColumn.CellTemplate>
                                    </sdk:DataGridTemplateColumn>

                                    <sdk:DataGridTextColumn Header="Descrição da Área Institucional" Binding="{Binding Path=Descricao}"  Width="*" />

                                    <sdk:DataGridTemplateColumn Width="60" Header="Utilizar">
                                        <sdk:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <CheckBox Name="chkUtilizarArea"
                                                          IsChecked="{Binding Path=UtilizaProcessamento}"
                                                          VerticalAlignment="Center"
                                                          HorizontalAlignment="Center"
                                                          Checked="chkUtilizarArea_Checked"
                                                          Unchecked="chkUtilizarArea_Unchecked"/>
                                            </DataTemplate>
                                        </sdk:DataGridTemplateColumn.CellTemplate>
                                    </sdk:DataGridTemplateColumn>

                                </sdk:DataGrid.Columns>
                            </sdk:DataGrid>
                            <sdk:Label Grid.Column="4" Style="{StaticResource LegendBlue}" Margin="0,0,-6,-6"
                                       VerticalAlignment="Bottom" HorizontalAlignment="Right" 
                                       ToolTipService.ToolTip="Quantidade de Áreas Institucionais"
                                       Content="{Binding DetalheAreasInstitucionais.Colecao.Count, FallbackValue='0'}"  />
                        </Grid>
                    </ContentControl>
                </Grid>

            </Grid>
        </toolkit:BusyIndicator>
    </Grid>
</navigation:Page>
